<template>
  <div class="ele-body ele-body-card">
    <!-- 顶部卡片 -->
    <a-card
      :bordered="true"
      :body-style="{padding: '20px'}">
      <div class="ele-cell workplace-user-card">
        <div class="ele-cell-content ele-cell">
          <a-progress :width="70" type="circle" :percent="100" :format="() => '柜子'" />
          <div class="ele-cell-content">
            <h4 class="ele-elip">柜子号：{{data.recordId}}</h4>
            <div class="ele-elip ele-text-secondary">
              <clock-circle-outlined/>
              <em>{{data.deviceTime}}</em>
            </div>
          </div>
        </div>
      </div>
    </a-card>

    <a-card
      :bordered="true"
      :body-style="{padding: '20px'}">
      <a-form
        ref="form"
        :model="paramForm"
        :rules="rules"
        :label-col="{ md: { span: 11 }, sm: { span: 24 } }"
        :wrapper-col="{ md: { span: 13 }, sm: { span: 24 } }"
        @submit="saveConfigToCmdQueue"
      >
        <!---------------- 计次模式下的时间段设置----------->
        <a-divider orientation="left"><a-tooltip color='orange' title=''>小计流量差数据设置</a-tooltip></a-divider>
        <a-alert message="时间块大小的单位分钟，范围是5到1440；流量差门限，单位0.01立方米" type="warning" />
        <a-row :gutter="8" style="margin-top : 20px;">
          <a-col :md="8" :sm="24" :xs="24">
            <a-form-item label="小计流量一的时间块大小:" name="SUBTOTAL1_TIME">
              <a-input-number :min="3" :max="1440" v-model:value="flowDiffJsonForm.SUBTOTAL1_TIME" placeholder="" allow-clear />
            </a-form-item>
            <a-form-item label="小计流量一的时间块大小:" name="SUBTOTAL2_TIME">
              <a-input-number :min="3" :max="1440" v-model:value="flowDiffJsonForm.SUBTOTAL2_TIME" placeholder="" allow-clear />
            </a-form-item>
            <a-form-item label="小计流量一的时间块大小:" name="SUBTOTAL3_TIME">
              <a-input-number :min="3" :max="1440" v-model:value="flowDiffJsonForm.SUBTOTAL3_TIME" placeholder="" allow-clear />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24" :xs="24">
            <a-form-item label="流量差门限:" name="SUBTOTAL1_DIFFER">
              <a-input v-model:value="flowDiffJsonForm.SUBTOTAL1_DIFFER" placeholder="" allow-clear />
            </a-form-item>
            <a-form-item label="流量差门限:" name="SUBTOTAL2_DIFFER">
              <a-input v-model:value="flowDiffJsonForm.SUBTOTAL2_DIFFER" placeholder="" allow-clear />
            </a-form-item>
            <a-form-item label="流量差门限:" name="SUBTOTAL3_DIFFER">
              <a-input v-model:value="flowDiffJsonForm.SUBTOTAL3_DIFFER" placeholder="" allow-clear />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24" :xs="24" >
            <a-form-item label="使能状态:" name="SUBTOTAL1_VALID">
              <a-select v-model:value="flowDiffJsonForm.SUBTOTAL1_VALID">
                <a-select-option :value="0">不使能</a-select-option>
                <a-select-option :value="1">使能</a-select-option>
              </a-select>
            </a-form-item>
            <a-form-item label="使能状态:" name="SUBTOTAL2_VALID">
              <a-select v-model:value="flowDiffJsonForm.SUBTOTAL2_VALID">
                <a-select-option :value="0">不使能</a-select-option>
                <a-select-option :value="1">使能</a-select-option>
              </a-select>
            </a-form-item>
            <a-form-item label="使能状态:" name="SUBTOTAL3_VALID">
              <a-select v-model:value="flowDiffJsonForm.SUBTOTAL3_VALID">
                <a-select-option :value="0">不使能</a-select-option>
                <a-select-option :value="1">使能</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="24" :xs="24" />
        </a-row>
        <a-row :gutter="8" style="margin-top : 20px;">
          <a-col :md="8" :sm="24" :xs="24">
            <a-form-item label="小计流量一的时间块大小:" name="SUBTOTAL1_TIME">
              <a-input-number :min="3" :max="1440" v-model:value="flowDiffJsonForm.SUBTOTAL1_TIME" placeholder="" allow-clear />
            </a-form-item>
            <a-form-item label="小计流量一的时间块大小:" name="SUBTOTAL2_TIME">
              <a-input-number :min="3" :max="1440" v-model:value="flowDiffJsonForm.SUBTOTAL2_TIME" placeholder="" allow-clear />
            </a-form-item>
            <a-form-item label="小计流量一的时间块大小:" name="SUBTOTAL3_TIME">
              <a-input-number :min="3" :max="1440" v-model:value="flowDiffJsonForm.SUBTOTAL3_TIME" placeholder="" allow-clear />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24" :xs="24">
            <a-form-item label="流量差门限:" name="SUBTOTAL1_DIFFER">
              <a-input v-model:value="flowDiffJsonForm.SUBTOTAL1_DIFFER" placeholder="" allow-clear />
            </a-form-item>
            <a-form-item label="流量差门限:" name="SUBTOTAL2_DIFFER">
              <a-input v-model:value="flowDiffJsonForm.SUBTOTAL2_DIFFER" placeholder="" allow-clear />
            </a-form-item>
            <a-form-item label="流量差门限:" name="SUBTOTAL3_DIFFER">
              <a-input v-model:value="flowDiffJsonForm.SUBTOTAL3_DIFFER" placeholder="" allow-clear />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24" :xs="24" >
            <a-form-item label="使能状态:" name="SUBTOTAL1_VALID">
              <a-select v-model:value="flowDiffJsonForm.SUBTOTAL1_VALID">
                <a-select-option :value="0">不使能</a-select-option>
                <a-select-option :value="1">使能</a-select-option>
              </a-select>
            </a-form-item>
            <a-form-item label="使能状态:" name="SUBTOTAL2_VALID">
              <a-select v-model:value="flowDiffJsonForm.SUBTOTAL2_VALID">
                <a-select-option :value="0">不使能</a-select-option>
                <a-select-option :value="1">使能</a-select-option>
              </a-select>
            </a-form-item>
            <a-form-item label="使能状态:" name="SUBTOTAL3_VALID">
              <a-select v-model:value="flowDiffJsonForm.SUBTOTAL3_VALID">
                <a-select-option :value="0">不使能</a-select-option>
                <a-select-option :value="1">使能</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="24" :xs="24" />
        </a-row>

        <!---------------- 饮水低谷时段的时间段设置----------->
        <a-divider orientation="left"><a-tooltip color='orange' title=''>饮水低谷时段数据设置</a-tooltip></a-divider>
        <a-row :gutter="8">
          <a-col :md="8" :sm="24" :xs="24">
            <a-form-item label="时间段一开始时间:" name="VALLEY_TIME1_START">
              <a-time-picker v-model:value="paramForm.VALLEY_TIME1_START" format="HH:mm" @change="selectValleyTime1Start"  allow-clear  />
            </a-form-item>
            <a-form-item label="时间段二开始时间:" name="VALLEY_TIME2_START">
              <a-time-picker v-model:value="paramForm.VALLEY_TIME2_START" format="HH:mm" @change="selectValleyTime2Start" allow-clear />
            </a-form-item>
            <a-form-item label="时间段三开始时间:" name="VALLEY_TIME3_START">
              <a-time-picker v-model:value="paramForm.VALLEY_TIME3_START" format="HH:mm" @change="selectValleyTime3Start" allow-clear />
            </a-form-item>
            <a-form-item label="时间段四开始时间:" name="VALLEY_TIME4_START">
              <a-time-picker v-model:value="paramForm.VALLEY_TIME4_START" format="HH:mm" @change="selectValleyTime4Start" allow-clear />
            </a-form-item>
            <a-form-item label='饮水低谷时段温度报警下限:' name='WARN_VALLEY_TEMP_LOW'>
              <a-input v-model:value='warnValleyJsonForm.WARN_VALLEY_TEMP_LOW' placeholder='饮水低谷时段温度报警下限' allow-clear />
              <a-alert message="精确到小数点后1位,范围从-500到900" style="margin-top:5px;font-size: 11px;padding:2px 3px;" type="info" show-icon />
            </a-form-item>
          </a-col>
          <a-col :md="7" :sm="24" :xs="24">
            <a-form-item label="结束时间(截止24:00):" name="VALLEY_TIME1_OVER">
              <time24-select :value="paramForm.VALLEY_TIME1_OVER" @modify="selectValley1Over" />
            </a-form-item>
            <a-form-item label="结束时间(截止24:00):" name="VALLEY_TIME2_OVER">
              <time24-select :value="paramForm.VALLEY_TIME2_OVER" @modify="selectValley2Over" />
            </a-form-item>
            <a-form-item label="结束时间(截止24:00):" name="VALLEY_TIME3_OVER">
              <time24-select :value="paramForm.VALLEY_TIME3_OVER" @modify="selectValley3Over" />
            </a-form-item>
            <a-form-item label="结束时间(截止24:00):" name="VALLEY_TIME4_OVER">
              <time24-select :value="paramForm.VALLEY_TIME4_OVER" @modify="selectValley4Over" />
            </a-form-item>
          </a-col>
          <a-col :md="9" :sm="24" :xs="24" />
        </a-row>

        <a-row style="margin-top: 20px;">
          <a-col :md="4" :sm="24" :xs="24">
            <a-form-item :wrapper-col="{ span: 12, offset: 5 }">
              <a-button v-permission="['PROPERTY_DEVICELIST_MGR_DRINKHEARTING_CONFIG_PARAMS_EDIT_BUTTON']" type="primary" html-type="submit" :loading='iconLoading'>
                保存并同步
              </a-button>
            </a-form-item>
          </a-col>
          <a-col :md="1" :sm="24" :xs="24" />
          <a-col :md='4' :sm='24' :xs='24'>
            <a-form-item :wrapper-col='{ span: 12, offset: 5 }'>
              <a-button v-permission="['PROPERTY_DEVICELIST_MGR_DRINKHEARTING_READ_CONFIG_BUTTON']" type='primary' html-type='button' @click='getParamsActionToCmdQueue' :loading='getParamsLoading'>
                读取设备的配置
              </a-button>
            </a-form-item>
          </a-col>
          <a-col :md="15" :sm="24" :xs="24" />
        </a-row>
      </a-form>
    </a-card>
  </div>
</template>

<script>
import ClockCircleOutlined from '@ant-design/icons-vue/lib/icons/ClockCircleOutlined';
import { message } from 'ant-design-vue';
import {DeviceCommandDownQueueApi} from '@/api/property/DeviceCommandDownQueueApi';
import {DeviceDrinkheatingConfigApi} from "@/api/property/drinkhearting/DeviceDrinkheatingConfigApi";
import Time24Select from '@/components/Time24Select/Time24Select.vue';
import dayjs from "dayjs";
export default {
  name: 'DeviceDrinkheartingConfigModeconfig',
  components: {
    ClockCircleOutlined,
    Time24Select
  },
  props: {
    data: Object
  },
  async mounted() {
  },
  async created() {
    await this.init()
  },
  data() {
    return {
      form : {},
      paramForm : {},
      flowDiffJsonForm : {},
      warnValleyJsonForm : {},
      rules: {

      },
      iconLoading: false,
      loadTimer: '',

      getParamsLoading : false,
      getParamsTimer : ''
    };
  },
  methods: {
    async init() {
      let _conf = await DeviceDrinkheatingConfigApi.detail({"recordId" : this.data.recordId});
      if (_conf) {
        this.form = _conf;
        let flowDiffJson = Object.assign({}, (_conf.flowDiffJson ? (JSON.parse(_conf.flowDiffJson) || {}) : {}));
        this.flowDiffJsonForm = flowDiffJson;
        if (flowDiffJson) {
          //转成数字
          this.flowDiffJsonForm.SUBTOTAL1_TIME = flowDiffJson.SUBTOTAL1_TIME ? Number(flowDiffJson.SUBTOTAL1_TIME) : 0;
          this.flowDiffJsonForm.SUBTOTAL2_TIME = flowDiffJson.SUBTOTAL2_TIME ? Number(flowDiffJson.SUBTOTAL2_TIME) : 0;
          this.flowDiffJsonForm.SUBTOTAL3_TIME = flowDiffJson.SUBTOTAL3_TIME ? Number(flowDiffJson.SUBTOTAL3_TIME) : 0;
          //使能状态
          this.flowDiffJsonForm.SUBTOTAL1_VALID = flowDiffJson.SUBTOTAL1_VALID ? Number(flowDiffJson.SUBTOTAL1_VALID) : 0;
          this.flowDiffJsonForm.SUBTOTAL2_VALID = flowDiffJson.SUBTOTAL2_VALID ? Number(flowDiffJson.SUBTOTAL2_VALID) : 0;
          this.flowDiffJsonForm.SUBTOTAL3_VALID = flowDiffJson.SUBTOTAL3_VALID ? Number(flowDiffJson.SUBTOTAL3_VALID) : 0;
        }

        let warnValleyJson = Object.assign({}, (_conf.warnValleyJson ? (JSON.parse(_conf.warnValleyJson) || {}) : {}));
        this.warnValleyJsonForm = warnValleyJson;
        if (warnValleyJson) {
          let _VALLEY_TIME1_START_HOUR = warnValleyJson.VALLEY_TIME1_START_HOUR ? Number(warnValleyJson.VALLEY_TIME1_START_HOUR) : 0,
            _VALLEY_TIME1_START_MIN = warnValleyJson.VALLEY_TIME1_START_MIN ? Number(warnValleyJson.VALLEY_TIME1_START_MIN) : 0,
            _VALLEY_TIME1_OVER_HOUR = warnValleyJson.VALLEY_TIME1_OVER_HOUR ? Number(warnValleyJson.VALLEY_TIME1_OVER_HOUR) : 0,
            _VALLEY_TIME1_OVER_MIN = warnValleyJson.VALLEY_TIME1_OVER_MIN ? Number(warnValleyJson.VALLEY_TIME1_OVER_MIN) : 0;
          this.paramForm.VALLEY_TIME1_START= dayjs( ((_VALLEY_TIME1_START_HOUR < 10 ? ("0" + _VALLEY_TIME1_START_HOUR) : _VALLEY_TIME1_START_HOUR) + ":" + (_VALLEY_TIME1_START_MIN < 10 ? ("0" + _VALLEY_TIME1_START_MIN) : _VALLEY_TIME1_START_MIN)), 'HH:mm');
          this.paramForm.VALLEY_TIME1_OVER = [_VALLEY_TIME1_OVER_HOUR, _VALLEY_TIME1_OVER_MIN];

          let _VALLEY_TIME2_START_HOUR = warnValleyJson.VALLEY_TIME2_START_HOUR ? Number(warnValleyJson.VALLEY_TIME2_START_HOUR) : 0,
            _VALLEY_TIME2_START_MIN = warnValleyJson.VALLEY_TIME2_START_MIN ? Number(warnValleyJson.VALLEY_TIME2_START_MIN) : 0,
            _VALLEY_TIME2_OVER_HOUR = warnValleyJson.VALLEY_TIME2_OVER_HOUR ? Number(warnValleyJson.VALLEY_TIME2_OVER_HOUR) : 0,
            _VALLEY_TIME2_OVER_MIN = warnValleyJson.VALLEY_TIME2_OVER_MIN ? Number(warnValleyJson.VALLEY_TIME2_OVER_MIN) : 0;
          this.paramForm.VALLEY_TIME2_START= dayjs( ((_VALLEY_TIME2_START_HOUR < 10 ? ("0" + _VALLEY_TIME2_START_HOUR) : _VALLEY_TIME2_START_HOUR) + ":" + (_VALLEY_TIME2_START_MIN < 10 ? ("0" + _VALLEY_TIME2_START_MIN) : _VALLEY_TIME2_START_MIN)), 'HH:mm');
          this.paramForm.VALLEY_TIME2_OVER = [_VALLEY_TIME2_OVER_HOUR, _VALLEY_TIME2_OVER_MIN];

          let _VALLEY_TIME3_START_HOUR = warnValleyJson.VALLEY_TIME3_START_HOUR ? Number(warnValleyJson.VALLEY_TIME3_START_HOUR) : 0,
            _VALLEY_TIME3_START_MIN = warnValleyJson.VALLEY_TIME3_START_MIN ? Number(warnValleyJson.VALLEY_TIME3_START_MIN) : 0,
            _VALLEY_TIME3_OVER_HOUR = warnValleyJson.VALLEY_TIME3_OVER_HOUR ? Number(warnValleyJson.VALLEY_TIME3_OVER_HOUR) : 0,
            _VALLEY_TIME3_OVER_MIN = warnValleyJson.VALLEY_TIME3_OVER_MIN ? Number(warnValleyJson.VALLEY_TIME3_OVER_MIN) : 0;
          this.paramForm.VALLEY_TIME3_START= dayjs( ((_VALLEY_TIME3_START_HOUR < 10 ? ("0" + _VALLEY_TIME3_START_HOUR) : _VALLEY_TIME3_START_HOUR) + ":" + (_VALLEY_TIME3_START_MIN < 10 ? ("0" + _VALLEY_TIME3_START_MIN) : _VALLEY_TIME3_START_MIN)), 'HH:mm');
          this.paramForm.VALLEY_TIME3_OVER = [_VALLEY_TIME3_OVER_HOUR, _VALLEY_TIME3_OVER_MIN];

          let _VALLEY_TIME4_START_HOUR = warnValleyJson.VALLEY_TIME4_START_HOUR ? Number(warnValleyJson.VALLEY_TIME4_START_HOUR) : 0,
            _VALLEY_TIME4_START_MIN = warnValleyJson.VALLEY_TIME4_START_MIN ? Number(warnValleyJson.VALLEY_TIME4_START_MIN) : 0,
            _VALLEY_TIME4_OVER_HOUR = warnValleyJson.VALLEY_TIME4_OVER_HOUR ? Number(warnValleyJson.VALLEY_TIME4_OVER_HOUR) : 0,
            _VALLEY_TIME4_OVER_MIN = warnValleyJson.VALLEY_TIME4_OVER_MIN ? Number(warnValleyJson.VALLEY_TIME4_OVER_MIN) : 0;
          this.paramForm.VALLEY_TIME4_START= dayjs( ((_VALLEY_TIME4_START_HOUR < 10 ? ("0" + _VALLEY_TIME4_START_HOUR) : _VALLEY_TIME4_START_HOUR) + ":" + (_VALLEY_TIME4_START_MIN < 10 ? ("0" + _VALLEY_TIME4_START_MIN) : _VALLEY_TIME4_START_MIN)), 'HH:mm');
          this.paramForm.VALLEY_TIME4_OVER = [_VALLEY_TIME4_OVER_HOUR, _VALLEY_TIME4_OVER_MIN];
        }


      }
    },

    selectValleyTime1Start(time) {
      this.warnValleyJsonForm.VALLEY_TIME1_START_HOUR = time.hour();
      this.warnValleyJsonForm.VALLEY_TIME1_START_MIN = time.minute();
    },
    selectValleyTime2Start(time) {
      this.warnValleyJsonForm.VALLEY_TIME2_START_HOUR = time.hour();
      this.warnValleyJsonForm.VALLEY_TIME2_START_MIN = time.minute();
    },
    selectValleyTime3Start(time) {
      this.warnValleyJsonForm.VALLEY_TIME3_START_HOUR = time.hour();
      this.warnValleyJsonForm.VALLEY_TIME3_START_MIN = time.minute();
    },
    selectValleyTime4Start(time) {
      this.warnValleyJsonForm.VALLEY_TIME4_START_HOUR = time.hour();
      this.warnValleyJsonForm.VALLEY_TIME4_START_MIN = time.minute();
    },

    selectValley1Over(time) {
      this.paramForm.VALLEY_TIME1_OVER = time;
      if (time) {
        this.warnValleyJsonForm.VALLEY_TIME1_OVER_HOUR = time[0];
        this.warnValleyJsonForm.VALLEY_TIME1_OVER_MIN = time[1];
      }
    },

    selectValley2Over(time) {
      this.paramForm.VALLEY_TIME2_OVER = time;
      if (time) {
        this.warnValleyJsonForm.VALLEY_TIME2_OVER_HOUR = time[0];
        this.warnValleyJsonForm.VALLEY_TIME2_OVER_MIN = time[1];
      }
    },

    selectValley3Over(time) {
      this.paramForm.VALLEY_TIME3_OVER = time;
      if (time) {
        this.warnValleyJsonForm.VALLEY_TIME3_OVER_HOUR = time[0];
        this.warnValleyJsonForm.VALLEY_TIME3_OVER_MIN = time[1];
      }
    },

    selectValley4Over(time) {
      this.paramForm.VALLEY_TIME4_OVER = time;
      if (time) {
        this.warnValleyJsonForm.VALLEY_TIME4_OVER_HOUR = time[0];
        this.warnValleyJsonForm.VALLEY_TIME4_OVER_MIN = time[1];
      }
    },

    checkProcess(sceneDictate, clearCallback, callback) {
      let params = {
        recordId: this.data.recordId,
        sceneDictate: sceneDictate
      };
      let result = DeviceCommandDownQueueApi.workingDetail(params);
      result
        .then(result => {
          if (!result || !result.dcdqId) { //处理完成了
            clearCallback && clearCallback(); //去掉菊花+清除循环调用
            callback && callback(); //用户自定义
          }
        })
        .catch(() => {
          clearCallback && clearCallback(); //去掉菊花+清除循环调用
        });
    },

    //保存配置处理
    clearConfigProcess(){
      this.iconLoading = false;
      clearInterval(this.loadTimer);
    },
    checkConfigProcess()
    {
      let that = this;
      this.checkProcess(23, this.clearConfigProcess, function(){
        that.init();
      });
    },
    saveConfigToCmdQueue()
    {
      let workerDetailparams = {
        recordId: this.data.recordId,
        sceneDictate: 23
      };
      let that = this;
      let existWorkerResult = DeviceCommandDownQueueApi.workingDetail2(workerDetailparams);
      existWorkerResult
        .then(workResult => {
          console.log(workResult);
          if (!workResult || !workResult.dcdqId) { //处理完成了
            that.save();
          } else {
            message.error('上一个配置还在推送中，请稍后重试');
            return;
          }
        })
        .catch((e) => {
          message.error(e);
        });
    },
    /**
     * 保存和编辑
     * 写到队列，队列发送完回写到原配置
     * @author cancan
     * @date 2022/03/04 21:15
     */
    save() {
      //将"结束时间"00：00转为24点吧。this.timeConfForm.TIME6_OVER_HOUR结束
      let flowDiffJson = this.flowDiffJsonForm;
      let warnValleyJsonForm = this.warnValleyJsonForm;
      console.log(flowDiffJson);
      let updateData = {
        flowDiffJson : JSON.stringify(flowDiffJson),
        warnValleyJsonForm : JSON.stringify(warnValleyJsonForm),
      };
      // 校验表单
      //await this.$refs.form.validate();
      // 修改加载框为正在加载
      this.loading = true;
      let updateDataRecord = {
        recordId: this.data.recordId,
        templateCode: 'drinkhearting',
        updateData: JSON.stringify({old : this.form, update : updateData}),
        dictate : 23,
        sceneDictate : 23
      };

      let result = DeviceCommandDownQueueApi.add(updateDataRecord);
      result.then(res => {
          // 移除加载框
          this.loading = false;
          // 提示添加成功
          message.success(res.message);

          this.iconLoading = true; //转圈
          this.loadTimer = setInterval(this.checkConfigProcess, 5000);
        })
        .catch(() => {
          this.loading = false;
        });
    },


    //读取参数
    clearGetParamsProcess(){
      this.getParamsLoading = false;
      clearInterval(this.getParamsTimer);
    },
    checkGetParamsProcess()
    {
      let that = this;
      this.checkProcess(56, this.clearGetParamsProcess, function(){
        that.init();
      });
    },
    getParamsActionToCmdQueue()
    {
      let workerDetailparams = {
        recordId: this.data.recordId,
        sceneDictate: 56
      };
      let that = this;
      let existWorkerResult = DeviceCommandDownQueueApi.workingDetail2(workerDetailparams);
      existWorkerResult
        .then(workResult => {
          console.log(workResult);
          if (!workResult || !workResult.dcdqId) { //处理完成了
            that.getParams();
          } else {
            message.error('上一个配置还在推送中，请稍后重试');
            return;
          }
        })
        .catch((e) => {
          message.error(e);
        });
    },

    getParams() { //读取配置
      this.loading = true;
      let updateData = {
        old: '',
        update: '',
      };
      let updateDataRecord = {
        recordId: this.data.recordId,
        templateCode: 'drinkhearting',
        updateData: JSON.stringify(updateData),
        dictate : 56,
        sceneDictate : 56
      };

      let result = DeviceCommandDownQueueApi.add(updateDataRecord);
      result
        .then(result => {
          // 移除加载框
          this.loading = false;
          // 提示添加成功
          message.success(result.message);

          this.getParamsLoading = true; //转圈
          this.getParamsTimer = setInterval(this.checkGetParamsProcess, 5000);
        })
        .catch(() => {
          this.loading = false;
        });
    }
  }
};
</script>
<style scoped>
/** 用户卡片 */
.workplace-user-card .ele-cell-content {
  overflow: hidden;
}

.workplace-user-card h4 {
  margin-bottom: 6px;
}
.regionclass /deep/ .ant-col-md-11 {
  max-width : 30% !important;
}
.regionclass /deep/ .ant-col-md-13 {
  max-width: 70% !important;
}
</style>
